Video Transitions using ARexx

Art Department Professional is one of the most powerful tools for professional Amiga users.  It is not a toy, yet can be enjoyable to use.  ASDG included a large number of interesting effects, but no easy way to use most of them in an animation.  FRED is great for simpler tasks, such as combining a large number of frames into an animation, however; when it comes to creating brand new animations, it can be difficult to achieve the desired results even with the included tutorials and scripts.

The best way to get all the power out of most of the operators is to write an ARexx script to control them or use one of the programs now available to help automate the writing process for you.  After all, who would want to perform an operation manually on a 500-frame animation?  But contrary to what a large number of people may think, writing and designing an ARexx script is easier than neurosurgery.

The purpose of this article is not to teach the ARexx basics, but rather to help someone who uses ADPro and would never consider using ARexx for anything.  Writing a script may seem like an imposing task at first, but if it is broken down into a few concise sections the task becomes much easier.

To simplify the task, it is useful to divide the writing process into three areas:  the idea, or what you want the script to accomplish; the theory, or which operators in combination can be used to give the desired effect; and the actual writing of the script.

Getting an idea can be the hardest of the three steps - after all, the effect being produced should be both effective and visually pleasing.  One way to get inspired is to watch a T.V. channel which may have a fair number of visual effects, such as a home shopping channel or a home viewing movie advertisement channel.

Once you have an idea, you must decide how to go about implementing it.  Unfortunately, there are few shortcuts; however, if you have even a vague impression of how to accomplish the effect, you should go into ADPro and try out a few scenarios to manually approximate your theories.  This will help you decide what works, or at least what doesn't work.  Often, it is quite helpful if you draw the effect on a piece of paper and then work from the drawing instead of from memory.

Finally, we have come to the implementation of the theory.  If you have never used ARexx before, I would suggest that you look through the scripts which come with ADPro as they can provide a wealth of information about how to write your own.

However, back to the first step for a moment.  In order to get an idea, one must be aware of the capabilities of the program.  Therefore, a few examples of effects will be provided to help you get some ideas.

Compositing

ADPro not only provides operators to manipulate individual images, but also gives the user the ability to composite two images together.  In all of the examples, compositing is the basis for the transitions, and thus, we will start with the simplest transition - the fade.  All that is involved here is changing the "fade factor" in each frame.  To see how this is accomplished, take a look at script #1.

The roll operator may seem like a fairly simple operator with little use by itself, but it does have some definite uses, especially in transitions between two screens.  For example, one transition that can be created using only roll would be a "push" style transition, where it appears that one image is pushing the other off the screen.  To accomplish this, use script #2, which uses the principles from the first script with the roll operator.

Of course, compositing can be used in many other ways.  In fact, if one does a "two-step" composition, virtually any effect can be achieved.  A "two-step" composition refers to using an intermediary image, generally consisting of two colors.  For our example, black and white will be used.  Imagine that there is a white circle in the middle of a black background.  This new picture should be the same size as the other two images.

To start the effect, load the first image.  Then load the intermediate image using compositing and allow the transparent color to be white.  If you were to view the picture now, there should be a circle in the middle of the image which contains the center of the other image.  The rest of the screen should be black.  Now save this temporary image and load the second image.  Finally, load the temporary image using compositing with a transparent color of black.  If you were to view the resulting picture, there should be a circle with the center of the first image which is surrounded by the second image.  This example is essentially the same as example four in the tutorial section of the ADPro manual, except that this example does not use the alpha channel option, as some older versions of ADPro do not have it.  It is important that you understand this example, as it is the basis for the following examples.

Animated Transitions

The use of the alpha channel gives an interesting effect, but is not terribly useful in its present form for animations.  So, we must modify it so that it will allow us to change the image sequentially.  The first step is to create a new intermediary image; however, this one must be three times as long along the x axis (i.e., if the original images are 320x200, the intermediary one must be 960x200).  Now, draw a pure white line on the intermediary image (this assumes that the intermediary image size is 960x200) from 320,199 to 639,0.  Now fill in the region below the line with the same white.  Then, be sure that the region to the right of the white triangle is also white all the way to the end of the image.  This is done so that we may gradually change the picture by moving the intermediary image along the x axis when compositing it onto the first image.

To create this new animation, increment the x position of the intermediate image when it is being composited onto the first image.  The parameters for the compositer in ARexx are as follows:  LOAD {filename} Xoffset Yoffset %composition transRed transGreen transBlue.  See script #3 for the complete code.  This effect could also be done in FRED, but would likely require more work, and would not be as easy to tweak to get it exactly as you want it.  This is a major benefit of ARexx scripts.

Of course, this script can be modified in many ways; for example, this transition could be performed vertically.  Another interesting variation of this theme is using a multicolored intermediary image.  To do this, create an image with dimensions of 740x200.  The pixels from 0,0 to 419,199 should be black and the pixels from 420,0 to 739,199 should be white.  This image can be divided into three parts.  The first part, from 0,0 to 319,199 should be entirely black and, when composited, will let the viewer see the entire first image.  The second part, from 420,0 to 739,199 should be entirely white, to allow the second image to be seen.  The third part, the middle, can contain anything you wish.  For example, it could contain an eagle pulling the second picture overtop of the first picture, or anything you desire.  If you have a 24-bit paint program, the middle can be quite realistic.  Perhaps you may even want to try using a digitized image.  The only restriction is that the background of this middle section must be black if you wish it to be transparent.  Another variant would be to use the roll operator in conjunction with compositing to give the impression that the first image is being pushed away by the second one.  This variation is shown in script #4.

The scripts provided with this article are relatively simple ones.  They can be as complex as you desire, with very few limitations.  The provided scripts should help in overcoming the initial hurdles in writing scripts if you are doing it manually, or, if you have one of the automation programs, by giving you new ideas on how to create new effects.


Script #1

/* 
** A simple script that uses
** compositing to go from
** one image to another.
*/

ADDRESS "ADPro"
OPTIONS RESULTS

numframes = 30
fadefactor = 0
startimage = "Work:Pic1.IFF"
endimage = "Work:Pic2.IFF"
animname = "Work:TestAnim"

DO loop = 1 to numframes

/*
** Change the weight of the
** image to be composited.
*/

   fadefactor=fadefactor+100/numframes

   LFORMAT "IFF"
   LOAD startimage

/*
** Add the second image to
** the first and remove decimals.
*/

   truncFade = trunc(fadefactor)

   LOAD endimage 0 0 truncFade
   
   DITHER 1
   RENDER_TYPE HAM
   EXECUTE

   SFORMAT "ANIM"
   SAVE animname IMAGE APPEND
END

SFORMAT "ANIM"
SAVE animname IMAGE WRAPUP


Script #2

/* 
** A sample script using the
** roll operator to "push" 
** one image off the screen.
*/

ADDRESS "ADPro"
OPTIONS RESULTS

numframes = 20

/*
** Generally zero.
*/

rightrollval = 0

/*
** Generally equal to the
** width of the images.
*/

leftrollval = 320
picwidth = 320

startimage = "Work:Pic1.IFF"
endimage = "Work:Pic2.IFF"
animname = "Work:TestAnim"
temppic = "RAM:TempPic.IFF"

DO loop = 1 to numframes-1

/*
** Increment the roll amount
** for the two images and truncate
** any decimal value.
*/

   rightrollval = rightrollval+picwidth/numframes
   leftrollval = leftrollval-picwidth/numframes
   
   truncRight = trunc(rightrollval)
   truncLeft = trunc(leftrollval)
   
   LFORMAT "IFF"
   LOAD startimage

   OPERATOR "ROLL" "RIGHT" truncRight NO_WRAP
   
/*
** Puts the first image into
** a buffer, where it is loaded
** later using the compositing
** option to add it to the second
** image.
*/

   SFORMAT "IFF"
   SAVE temppic RAW 
   
   LOAD endimage 
   OPERATOR "ROLL" "LEFT" truncLeft NO_WRAP
   
   LOAD temppic 0 0 100 0 0 0

   DITHER 1
   RENDER_TYPE HAM
   EXECUTE

   SFORMAT "ANIM"
   SAVE animname IMAGE APPEND
END

/*
** ADPro's ROLL operator will
** not allow an image to be rolled
** by the width of the image,
** therefore, the final image must
** be loaded separately.
*/

LOAD endimage

DITHER 1
RENDER_TYPE HAM
EXECUTE

SFORMAT "ANIM"
SAVE animname IMAGE APPEND
SAVE animname IMAGE WRAPUP


Script #3

/* 
** A script which uses a
** middle B&W image as a
** pattern for a transition.
*/

ADDRESS "ADPro"
OPTIONS RESULTS

numframes=20

/*
** Size of the intermediate image
*/

intermediateX = 960 
imageX = 320 /* Picture size */

sizeX = intermediateX - imageX
whereX = 0 /* How much to roll */

startpic = "Work:Pic1.IFF"
endpic = "Work:Pic2.IFF"
intermediate = "Work:Background.IFF"
bufferfile = "RAM:TempPic.IFF" /* Temporary file */
animname = "Work:TestAnim"

DO loop = 1 to numframes
   LFORMAT "IFF"
   LOAD startpic

/*
** Loads and composites the
** "transition" screen, then
** saves it for later composition.
** Uses black as the transparent
** color so the first image is
** unchanged where black existed
** in the intermediate, but white
** was laid directly onto the
** original image.
*/

   roundX=trunc(whereX) /* Makes an integer */
    
   LOAD intermediate roundX 0 100 0 0 0
   
   SFORMAT "IFF"
   SAVE bufferfile RAW 
   
   LOAD endpic 
  
/*
** Composites the image
** saved earlier.
*/  
  
   LOAD bufferfile 0 0 100 255 255 255

   RENDER_TYPE HAM
   EXECUTE

/*
** Changes the offset for
** the next frame.
*/

   whereX=whereX-sizeX/(numframes-1)

   SFORMAT "ANIM"
   SAVE animname IMAGE APPEND
END

SFORMAT "ANIM"
SAVE animname IMAGE WRAPUP



Script #4

/* 
** A script which uses a 24-bit
** intermediate image as a
** pattern for the transition.
*/

ADDRESS "ADPro"
OPTIONS RESULTS

numframes = 40

width = 320 /* Width of the image */
middle = 100 /* Width of the middle block */

sizeX = width + middle
whereX = 0 /* Generally zero */

startimage = "Work:Pic1.IFF"
endimage = "Work:Pic2.IFF"
intermediate = "Work:ColorBackground.IFF"
temppic = "RAM:TempPic.IFF" /* A buffer file */
animname = "Work:TestAnim"

DO loop = 1 to numframes

/*
** This changes the value required for
** rolling the first image to the left.
** If it is negative, ADPro does not roll.
*/
   roundX = trunc(whereX)

   rollvar = -roundX - middle
   
   LFORMAT "IFF"
   LOAD startimage
   
   OPERATOR "ROLL" "LEFT" rollvar NO_WRAP

/*
** Loads and composites the
** intermediate image onto the
** original, leaving the original
** untouched after the roll, but
** adds the middle image giving
** movement (i.e., biplane, logo).
** Also changes black portion of
** screen to white for later
** composition.
*/
   
   LOAD intermediate roundX 0 100 0 0 0
   
   SFORMAT "IFF"
   SAVE temppic RAW
      
   LOAD endimage
   
/*
** Changes value needed for moving
** the second image to the left
*/ 
   
   rollvar = sizeX + roundX
   OPERATOR "ROLL" "RIGHT" rollvar NO_WRAP
   
/*
** Loads and composites the first
** image onto the second one.
*/

   LOAD temppic 0 0 100 255 255 255

   DITHER 1
   RENDER_TYPE HAM
   EXECUTE

/*
** Change the offset of
** the next frame.
*/

   whereX=whereX-sizeX/(numframes-1)

   SFORMAT "ANIM"
   SAVE animname IMAGE APPEND
END

SFORMAT "ANIM"
SAVE animname IMAGE WRAPUP


Written by:  Jason R. Hardy

55 Selwyn Place
Kanata, Ontario
K2K 1P1
CANADA

Phone:  (613) 781-7645
